<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">

                    <form id="form2" class="form-inline" action="" method="get">
                        <?php echo csrf_hidden();?>
                        开始时间：<input type="text" class="form-control demo-input starttime" name='starttime' placeholder="开始日期" id="test1">
                        结束时间：<input type="text" class="form-control demo-input endtime" name='endtime' placeholder="结束日期" id="test2">
                        <span class="btn btn-purple btn-sm" id="excel">
                            <span class=" icon-on-right bigger-110"></span>
                            导出excel
                        </span>
                    </form>
                    <div class="col-xs-12">

                        </div>
                        
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                <th>订单号</th>
                                <th class="center">下单人</th>
                                <th class="center">支付方式</th>
                                <th class="center">支付状态</th>
                                <th class="center">订单总价</th>
                                <th class="center">下单时间</th>
                                <th class="center">期望交货时间</th>
                                <th class="center">订单状态</th>
                                <th class="center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if($orders){?>
                            <?php foreach ($orders as $key => $val) { ?>
                                <tr>
                                    <td class="center">
                                        <input class="uids" type="checkbox" name="gids[]" value="<?php echo $val['order_id'];?>">
                                    </td>
                                    <td><?php echo $val['order_no']; ?></td>
                                    <td class="center"><?php echo $val['user_name']; ?></td>
                                    <td class="center">
                                    <?php if($val['order_pay_type'] == 0) {?>
                                        <span class="label">未支付</span>
                                    <?php }?>
                                    <?php if($val['order_pay_type'] == 2) {?>
                                    <span class="label label-sm label-info arrowed arrowed-righ">线下支付</span>
                                    <?php }?>
                                    <?php if($val['order_pay_type'] == 1) {?>
                                    <span class="label label-sm label-info arrowed arrowed-righ">销售贷支付</span>
                                    <?php }?>
                                    </td>
                                    <td class="center">
                                    <?php if($val['order_pay'] == 0) {?>
                                    <span class="label label-sm label-info arrowed arrowed-righ">未支付</span>
                                    <?php }?>
                                    <?php if($val['order_pay'] == 1) {?>
                                    <span class="label label-sm label-info arrowed arrowed-righ">已支付</span>
                                    <?php }?>
                                    </td>
                                    <td><?php echo $val['order_price']; ?></td>
                                    <td><?php echo date("Y-m-d H:i:s",$val['order_add_time']); ?></td>
                                    <td class="center"><?php echo !empty($val['good_date']) ? $val['good_date'] :'---';?></td>
                                    <td class="center">
                                        <?php if(($val['order_pay'] == 1) && ($val['order_status'] == 0)){?>
                                            <span class="label label-sm label-info arrowed arrowed-righ">待确认收款</span>
                                        <?php } ?>
                                        <?php if(($val['order_pay'] == 0) && ($val['order_status'] == 0)){?>
                                            <span class="label label-sm label-info arrowed arrowed-righ">待下单支付</span>
                                        <?php } ?>
                                        <?php if($val['order_status'] == 1) {?>
                                            <span class="label label-sm label-info arrowed arrowed-righ">待送货</span>
                                        <?php }?>
                                        <?php if($val['order_status'] == 2) {?>
                                            <span class="label label-sm label-info arrowed arrowed-righ">待收货</span>
                                        <?php }?>
                                        <?php if($val['order_status'] == 3) {?>
                                            <span class="label label-sm label-info arrowed arrowed-righ">已完成</span>
                                        <?php }?>
                                    </td>
                                    <td class="center">
                                        <?php if($val['order_pay'] == 0) {?>
                                            <a class="green zhifu" href="<?php echo site_url(X_URL.'orders/pay_order/'.$val['order_no']);?>" title="去支付">去支付</a>
                                        <?php }?>
                                        <?php if(($val['order_status'] == 1) && ($this->auth->is_super_admin())) {?>
                                            <a class="green fahuo" href="javascript:;" val="<?php echo site_url(X_URL.'orders/get_status/'.$val['order_id']."/2");?>" title="发货">发货</a>
                                        <?php }?>
                                        <?php if($val['order_pay'] == 1) {?>
                                            <a href="<?php echo site_url(X_URL.'orders/show_orders/'.$val['order_id']);?>">查看订单</a>&nbsp;
                                        <?php }?>
                                        <?php if(($this->auth->is_super_admin()) && ($val['order_pay_type'] == 2) && ($val['order_pay'] == 1) && ($val['order_status'] == 0)) {?>
                                            <a class="green shoukuan" href="javascript:;" val="<?php echo site_url(X_URL.'orders/get_status/'.$val['order_id']."/1");?>" title="确认收款">确认收款</a>
                                        <?php }?>
                                    </td>
                                </tr>
                            <?php } ?>
                            <?php } ?>
                            </tbody>
                        </table>
                        <?php if($pagination){?><ul class="pagination"><?php echo $pagination;?></ul><?php }?>
                        
<!--                        {$page}-->
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
    </div><!-- /.main-content -->

<?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<?php echo admin_js_url('laydate');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    //执行一个laydate实例
    laydate.render({
        elem: '#test1' //指定元素
    });
    laydate.render({
        elem: '#test2' //指定元素
    });
    $("#excel").click(function () {
        var starttime = $("#test1").val();
        var endtime = $("#test2").val();
        var url = baseurl+"index.php/manage/orders/export_excel";

        window.location.href=url+"?starttime="+starttime+"&endtime="+endtime;
    });
   $(".fahuo").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "确定此订单发货吗?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });

   $(".shoukuan").click(function () {
       var url = $(this).attr('val');
       bootbox.confirm({
           title: "系统提示",
           message: "确定此订单收到线下打款吗?",
           callback: function (result) {
               if (result) {
                   window.location.href = url;
               }
           },
           buttons: {
               "cancel": {"label": "取消"},
               "confirm": {
                   "label": "确定",
                   "className": "btn-danger"
               }
           }
       });
   });
</script>
</body>
</html>
